import Vue from 'vue'
import myRouter from 'vue-router'
import Layout from '../views/layout/Layout.vue'


Vue.use(myRouter)


export const constantRouterMap = [

  {
    path: '/login',
    // 懒加载模式
    component: () => import('@/views/login.vue'),
    hidden: true
  },

  {
    path: '/edite',
    component: () => import('@/views/BlogEdite.vue'),
  },

  {
    path: '/',
    component: Layout,
    redirect: '/publish',
    children: [
      {
        path: 'publish',
        component: () => import('@/views/articleAdd.vue'),
        meta: { title: '文章发表', icon: 'form'}
      }
    ]
  },


  {
    path: '/fileUpload',
    component: Layout,
    redirect: '/fileUpload',
    children: [
      {
        path: 'fileUpload',
        component: () => import('@/views/FileUpload.vue'),
        meta: { title: '图片管理', icon: 'form'}
      }
    ]
  },


  {
    path: '/list',
    component: Layout,
    redirect: '/list/manage',
    meta: { title: '文章管理', icon: 'table'},
    children: [
      {
        path: 'manage',
        component: () => import('@/views/articleList.vue'),
        meta: {title: '文章列表', icon: 'table'}
      }
      ,
      {
        path: 'analyse',
        component: () => import('@/views/articleAnalyse.vue'),
        meta: {title: '文章统计', icon: 'tree'}
      }
    ]
  },



  {
    // 路由匹配失败时 就重定向404页面
    path: '*',
    redirect: '/404',
    hidden: true
  } ,
  {
    path: '/404',
    component: () => import('@/views/404.vue'),
    hidden: true
  }

]

export default new myRouter({
  // 去除 url 中的 #
  // mode: 'history',
  base: '/blogsys/',
  routes: constantRouterMap
})
